package com.hsav.kcxb.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import com.hsav.kcxb.R;
import com.hsav.kcxb.bean.FileBean;

import java.io.Serializable;

public class FileDetailActivity extends BaseActivity {

    private static final String TAG = FileDetailActivity.class.getSimpleName();
    private TextView mNameTx;
    private TextView mSizeTx;
    private TextView mTypeTx;
    private TextView mDateTx;
    private TextView mHasDownloadTx;
    private TextView mHasSharedTx;
    private TextView mDescTx;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_file_detail);
        initView();
        handleIntent();
    }

    private void initView() {
        mNameTx = (TextView)findViewById(R.id.tx_file_name);
        mSizeTx = (TextView)findViewById(R.id.tx_file_size);
        mTypeTx = (TextView)findViewById(R.id.tx_file_type);
        mDateTx = (TextView)findViewById(R.id.tx_file_date);
        mHasDownloadTx = (TextView)findViewById(R.id.tx_file_has_download);
        mHasSharedTx = (TextView)findViewById(R.id.tx_file_has_shared);
        mDescTx = (TextView)findViewById(R.id.tx_file_desc);

    }

    private void handleIntent() {
        Intent intent = getIntent();
        FileBean file = (FileBean)intent.getSerializableExtra("file");
        Log.i(TAG,"file="+file);
        if(file!=null){
            mNameTx.setText(file.getFileName());
            mSizeTx.setText(file.getSize()+"");
            mTypeTx.setText(file.getType());
            mDateTx.setText(file.getDate());
            mDescTx.setText(file.getDesc());
            if(file.isHasDownLoaded()){
                mHasDownloadTx.setText("是");
            }else{
                mHasDownloadTx.setText("否");
            }
            if(file.isHasShared()){
                mHasSharedTx.setText("是");
            }else{
                mHasSharedTx.setText("否");
            }
        }
    }
}
